<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="vue.js"></script>
    <script src="index.js"></script>
    <link rel="stylesheet" href="index.css">
    <style>
        .el-header, .el-footer {
            background-color: #B3C0D1;
            color: #333;
            text-align: left;
            line-height: 60px;
        }

        .el-aside {
            background-color: #D3DCE6;
            color: #333;
            text-align: center;
            line-height: 200px;
        }

        .el-main {
            background-color: #E9EEF3;
            color: #333;
            text-align: center;
        }

        /*找到html标签、body标签，和挂载的标签*/
        /*都给他们统一设置样式*/
        html,body,.el-container{
            /*设置内部填充为0，几个布局元素之间没有间距*/
            padding: 0px;
            /*外部间距也是如此设置*/
            margin: 0px;
            /*统一设置高度，高度自行调整*/
            height: 1200px;
        }

    </style>
</head>
<body>
        <div id="app">
            <el-container>
                <el-header>顶部</el-header>
                <el-container>
                    <el-aside>侧边栏容器</el-aside>
                    <el-main>

                        <el-form :model="formdata" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
                            <el-form-item label="活动名称" prop="name">
                                <el-input v-model="formdata.name"></el-input>
                            </el-form-item>

                            <el-form-item>
                                <el-button type="primary" @click="submitForm">立即创建</el-button>
                                <el-button @click="resetForm('ruleForm')">重置</el-button>
                            </el-form-item>
                        </el-form>

                    </el-main>
                </el-container>
                <el-container>
                    <el-footer>底部区域</el-footer>
                </el-container>
            </el-container>
        </div>
<script>
    var  vm = new Vue({
        el:"#app",
        methods:{
            submitForm(){
                this.$refs['ruleForm'].validate((valid)=>{
                        if(valid){
                            // axios(this.formdata)
                            alert("submit")
                        }else{
                            this.$message.error("表单校验失败")
                        }
                })
            }
        },
        data:{

            formdata:{
                name:''
            },
            rules: {
                name: [
                    {required: true, message: '请输入活动名称', trigger: 'blur'},
                    {min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur'}
                ]
            }
        }
    })
</script>
</body>
</html>